(function () {
    'use strict';

    angular
    .module('app')
    .factory('APIGoodsService', APIGoodsService);

    APIGoodsService.$inject = ['$http', '$q', '$timeout', 'CacheFactory', 'ENUM'];

    function APIGoodsService($http, $q, $timeout, CacheFactory, ENUM) {

        var service = new APIEndpoint( $http, $q, $timeout, CacheFactory, 'APIGoodsService' );

        service.getList = function( params ) {
            return this.fetch( '/weixin/goods/getList', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.getOne = function( params ) {
            return this.fetch( '/weixin/goods/getOne', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.getPartList = function( params ) {
            return this.fetch( '/weixin/pig/getPartList', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.getOnePart = function( params ) {
            return this.fetch( '/weixin/pig/getOnePart', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.getOnePig = function( params ) {
            return this.fetch( '/weixin/pig/getOne', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        return service;

    }

})();
